package principale.presentation.gui.interfacciaGraficaPura;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import principale.presentation.gui.operazioniLogiche.ButtonAscoltatoreMenu;

public class Menu {
	private JMenuBar menuBar;
	public Menu() {
		menuBar = new JMenuBar();
		JMenu menuFile=creaFile();
		JMenu menuEdit=creaEdit();
		JMenu menuAiuto=creaAiuto();
		menuBar.add(menuFile);
		menuBar.add(menuEdit);
		menuBar.add(menuAiuto);
	}
	public JMenu creaFile() {
		JMenu menu = new JMenu("File");
		JMenuItem menuItem;
		menuItem = new JMenuItem("Aggiungi Persona...");
		menuItem.setAccelerator(KeyStroke.getKeyStroke(
				KeyEvent.VK_N, ActionEvent.CTRL_MASK));
		menuItem.addActionListener(new ButtonAscoltatoreMenu(0));
		menu.add(menuItem);
		menuItem = new JMenuItem("Esci...");
		menuItem.setAccelerator(KeyStroke.getKeyStroke(
				KeyEvent.VK_X, ActionEvent.CTRL_MASK));
		menuItem.addActionListener(new ButtonAscoltatoreMenu(3));
		menu.add(menuItem);
		return menu;
	}
	public JMenu creaEdit() {
		JMenu menu = new JMenu("Edit");
		JMenuItem menuItem;
		menuItem = new JMenuItem("Modifica Persona...");
		menuItem.setAccelerator(KeyStroke.getKeyStroke(
				KeyEvent.VK_M, ActionEvent.CTRL_MASK));
		menuItem.addActionListener(new ButtonAscoltatoreMenu(1));
		menu.add(menuItem);
		
		menuItem = new JMenuItem("Elimina Persona...");
		menuItem.setAccelerator(KeyStroke.getKeyStroke(
				KeyEvent.VK_E, ActionEvent.CTRL_MASK));
		menuItem.addActionListener(new ButtonAscoltatoreMenu(2));
		menu.add(menuItem);
		
		menuItem = new JMenuItem("Gestire utenti...");
		menuItem.setAccelerator(KeyStroke.getKeyStroke(
				KeyEvent.VK_G, ActionEvent.CTRL_MASK));
		menuItem.addActionListener(new ButtonAscoltatoreMenu(5));
		menu.add(menuItem);
		return menu;
	}

	public JMenu creaAiuto() {
		JMenu menu = new JMenu("Aiuto");
		JMenuItem menuItem;
		menuItem = new JMenuItem("Informazione...");
		menuItem.addActionListener(new ButtonAscoltatoreMenu(4));
		menu.add(menuItem);
		return menu;
	}
	public JMenuBar getMenuBar() {
		return menuBar;
	}
}
